@extends('admin.layouts.index')
@section('title', '小程序列表')
@section('content')
<div class="row">
    <div class="col-md-12">
        <div class="card">
            <div class="card-body">
                <form class="m-search" method="GET" action="{{ URL::current() }}">
                    <div class="m-search-items">
                        <div class="m-search-item">
                            <label>小程序名称</label>
                            <input type="text" name="name" placeholder="请输入小程序名称">
                        </div>
                        <div class="m-search-item">
                            <label>小程序APPID</label>
                            <input type="text" name="appid" placeholder="请输入小程序APPID">
                        </div>
                        <div class="m-search-item">
                            <label>用户ID</label>
                            <input type="text" name="users_id" placeholder="请输入用户ID">
                        </div>
                        <div class="m-search-item">
                            <button class="button">搜索</button>
                        </div>
                    </div>
                </form>

                <div class="self-table-responsive">
                    <table class="table table-bordered table-nowrap">
                        <thead>
                            <tr>
                                <th scope="col">AppID</th>
                                <th scope="col">小程序名称</th>
                                <th scope="col">绑定方式</th>
                                <th scope="col">检测状态<i class="bx bxs-help-circle" id="tooltip_wechat1" data-bs-toggle="tooltip" data-bs-placement="right" title="系统自动检测小程序暂停，如出现异常会自动切换以及推送通知！"></i></th>
                                <th scope="col">创建时间</th>
                                <th scope="col">使用状态<i class="bx bxs-help-circle" id="tooltip_wechat1" data-bs-toggle="tooltip" data-bs-placement="right" title="小程序使用状态,如更新为禁用状态则创建链接无法选择且不会自动切换到此小程序。"></i></th>
                                <th scope="col">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            @forelse($linkListMinapps as $linkListMinapp)
                            <tr id="miniapp_{{ $linkListMinapp->appid }}">
                                <td>{{ $linkListMinapp->appid }}</td>
                                <td>{{ mb_strlen($linkListMinapp->name) > 5 ? mb_substr($linkListMinapp->name,0,5)."..." : $linkListMinapp->name }}</td>
                                @if($linkListMinapp->miniapp_type == 1)
                                <td>后台上架</td>
                                @elseif($linkListMinapp->miniapp_type == 2)
                                <td>密钥绑定</td>
                                @elseif($linkListMinapp->miniapp_type == 3)
                                <td>API接入</td>
                                @else
                                <td>扫码授权</td>
                                @endif
                                @if($linkListMinapp->visitstatus == 1)
                                <td class="text-success">检测正常</td>
                                @elseif($linkListMinapp->visitstatus == 2)
                                <td class="text-warning">暂停服务</td>
                                @elseif($linkListMinapp->visitstatus == 3)
                                <td>未知异常</td>
                                @elseif($linkListMinapp->visitstatus == 4)
                                <td class="text-danger">小程序封禁</td>
                                @else
                                <td>未开启检测</td>
                                @endif
                                <td>{{ $linkListMinapp->created_at }}</td>
                                @if($linkListMinapp->disable == 1)
                                <td>可用</td>
                                @elseif($linkListMinapp->disable == 3)
                                <td class="text-success">使用中</td>
                                @elseif($linkListMinapp->disable == 4)
                                <td class="text-danger">已删除</td>
                                @elseif($linkListMinapp->disable == 5)
                                <td>其他</td>
                                @else
                                <td class="text-danger">禁用</td>
                                @endif
                                <td>
                                    <div class="table-handdle-td">
                                        <a onclick="updateMiniapp('{{ $linkListMinapp->appid }}','{{ $linkListMinapp->miniapp_type }}');" href="javascript:;" class="table-handdle-link">更新小程序</a>
                                        <div class="dropdown-handle table-handdle-menu" data-bs-toggle="dropdown"  aria-expanded="false">
                                            <font>更多操作</font>
                                            <i class="bx bx-chevron-down"></i>
                                        </div>
                                        <div class="dropdown-menu">
                                            <a href="javascript:;" class="dropdown-item" onclick='mviewNotification("info","开启检测提醒","开启后系统会自动检测小程序是否被微信封禁或下架；如检测到异常会自动切换链接小程序以及推送提醒，请确认是否开启？","前往开启检测","取消",{"type":"minapp_check","appid":"{{ $linkListMinapp->appid }}"});'>开启小程序状态检测</a>
                                            @if($linkListMinapp->disable == 2)
                                            <a href="{{ url('/admin/miniapp/minapp_disable',['appid'=>$linkListMinapp->appid]) }}" class="dropdown-item text-warning">解除小程序禁用</a>
                                            @else
                                            <a class="dropdown-item text-warning" href="{{ url('/admin/miniapp/minapp_disable',['appid'=>$linkListMinapp->appid]) }}">禁用小程序</a>
                                            @endif
                                            <a href="javascript:;" class="dropdown-item text-danger" onclick='mviewNotification("warning","链接小程序提醒","删除小程序后链接可能无法使用,您确定要删除吗？","确认删除","取消",{"type":"minapp_delete","appid":"{{ $linkListMinapp->appid }}"});'>删除小程序</a>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            @empty
                            <tr>
                                @if(Auth::user()->authority == 3)
                                <td colspan="8">没有找到您要的小程序数据!</td>
                                @else
                                <td colspan="7">您当前暂未添加小程序;点击<a href="{{ url('/admin/miniapps/bind_mini_programs') }}">前往绑定小程序</a>!</td>
                                @endif
                            </tr>
                            @endforelse
                        </tbody>
                    </table>
                    <div class="pagination-container">
                        {!! $linkListMinapps->appends($condition)->render() !!}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="https://file.wailian1.cn/admin/assets/admin/js/public/miniapp.setting.min.js"></script>
@endsection
